package com.xigua._位或运算;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/3/2221:30
 */
public class _剑指Offer65_不用加减乘除做加法 {

    public static void main(String[] args) {
        System.out.println(add1(3, 8));
    }

    public static  int add(int a, int b) {
        while (b!=0){
            int c = (a&b)<<1;
            a = a^b;
            b=c;
        }
        return a;
    }

    public static  int add1(int a, int b) {
        if (b==0)return a;
        return add1(a^b,(a&b) <<1);
    }
}
